package com.lkx.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @Author likaixuan
 * @Description
 * @Create Date  2018/8/30 17:57
 * @Version 1.0
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2).groupName("秒杀从0到1构建案例").apiInfo(apiInfo()).select()
                .apis(RequestHandlerSelectors.basePackage("com.lkx.controller")).paths(PathSelectors.any()).build();
    }
    // 预览地址:swagger-ui.html
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder().title("SpringBoot 中使用Swagger2构建文档").termsOfServiceUrl("http://www.likaiuxan.top")
                .contact(new Contact("秒杀 ", "http://www.likaiuxan.top", "934268568@qq.com")).version("1.0").description("秒杀从0到1构建案例").build();
    }
}
